<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title></title>
	</head>

	<body>
		<script type="text/javascript">
			/********************
			1.请为网吧做一套系统，用于凭借身份证号码检测一个人是否成年，成年则欢迎，不成年则请出。
			提示：new Date();获取时间
				 string.sub();截取字符串
			********************/
			haoma = "440108199808285616"
			haoma = parseInt(haoma.sub(6, 9));
			var now = new Date();
			if((now.getYear - haoma) > 18) {
				alert("你已经成年");
			} else {
				alert("小屁孩");
			}

			/********************
			2.用至少两种定义对象的方式来定义一辆车，车有对应的属性（例如有尺寸，颜色，马力）和方法（行驶，开车灯）
			（请至少写出8个属性，5种方法）
			********************/
			//--------------------第一种:直接变量------------------------------
			var car1 = new Object;
			car1.name = "宝马 xDrive35i";
			car1.size = "2.8米";
			car1.color = "天蓝色";
			car1.power = "340匹";
			car1.type = "SUV";
			car1.box = "8挡手自一体";
			car1.maxSpeed = "240km/h";
			car1.rem = 5800;
			car1.run = function() {
				alert(this.name + "已开启");
			}
			car1.info = function() {
				alert(this.name + "长度为:" + this.size);
			}
			car1.time = function(allLength) {
				alert("行驶" + allLength + "米,总用时为:" + (allLength / parseInt(car1.maxSpeed)) + "小时");
			}
			car1.carType = function() {
				alert("这部车的马力是:" + car1.power);
			}
			car1.carBox = function() {
				alert("这部车的变速箱为:" + car1.box);
			}
			car1.run();
			car1.info();
			car1.time(480);
			car1.carType();
			car1.carBox();
			//----------------------------------------------------------------

			//--------------------第二种:混合模式------------------------------
			function car(name, size, color, power, type, box, maxSpeed, rem) {
				this.name = name;
				this.size = size;
				this.color = color;
				this.power = power;
				this.type = type;
				this.box = box;
				this.maxSpeed = maxSpeed;
				this.rem = rem;
			}
			car.prototype.run = function() {
				alert(this.name + "已开启");
			}
			car.prototype.info = function() {
				alert(this.name + "长度为:" + this.size);
			}
			car.prototype.time = function(allLength) {
				alert("行驶" + allLength + "米,总用时为:" + (allLength / parseInt(this.maxSpeed)) + "小时");
			}
			car.prototype.carType = function() {
				alert("这部车的马力是:" + car1.power);
			}
			car.prototype.carBox = function() {
				alert("这部车的变速箱为:" + car1.box);
			}
			var car2 = new car("宝马 xDrive35i", "2.8米", "天蓝色", "340匹", "SUV", "8挡手自一体", "240km/h", 5800);
			car2.run();
			car2.info();
			car2.time(480);
			car2.carType();
			car2.carBox();
			//----------------------------------------------------------------
		</script>
	</body>

</html>